<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.org/schema/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="http://richfaces.org/a4j"

	xmlns:p="http://primefaces.org/ui" 
	
	template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="simulado" styleClass="edit">

			<p:panel >
				<f:facet name="header">#{simuladoHome.managed ? 'Edit' : 'Add'} Simulado &gt; #{empty simuladoHome.simuladoId  ? 'Nova' : simuladoHome.simuladoId} </f:facet>


					<s:decorate id="descricaoField" template="/layout/edit.xhtml">
						<ui:define name="label">Descrição</ui:define>
						<p:inputTextarea id="descricao" cols="80" rows="2"
							value="#{simuladoHome.instance.descricao}" />
					</s:decorate>


					<s:decorate id="dinamicaField" template="/layout/edit.xhtml">
						<ui:define name="label">Dinâmica</ui:define>
						<p:selectBooleanCheckbox id="dinamica"
							value="#{simuladoHome.instance.dinamica}">

						</p:selectBooleanCheckbox>
					</s:decorate>


					<s:decorate id="disponivel_ateField" template="/layout/edit.xhtml">
						<ui:define name="label">Disponível até</ui:define>
						<p:calendar id="disponivel"
							value="#{simuladoHome.instance.disponivel_ate}"
							datePattern="MM/dd/yyyy hh:mm a" />
					</s:decorate>


					<s:decorate id="quantidade_questaoField"
						template="/layout/edit.xhtml">
						<ui:define name="label">Quantidade de questões</ui:define>
						<p:inputText id="quantidade_questao"
							value="#{simuladoHome.instance.quantidade_questao}">
						</p:inputText>
					</s:decorate>





					<s:decorate id="tempo_repostaField" template="/layout/edit.xhtml">
						<ui:define name="label">Tempo de reposta</ui:define>

						<p:spinner max="120" min="0"
							value="#{simuladoHome.instance.tempo_reposta}" >
						</p:spinner>
						<h:outputText value="Minutos" />
					</s:decorate>
					<s:decorate id="statusField" template="/layout/edit.xhtml">
						<ui:define name="label">Status</ui:define>
						<p:selectOneMenu value="#{simuladoHome.instance.status}">

							<s:selectItems value="#{statusSimuladoList.resultList}" var="i"
								label="#{i.descricao}"></s:selectItems>
							<s:convertEntity />

						</p:selectOneMenu>
					</s:decorate>
					<s:decorate id="tagsField" template="/layout/edit.xhtml">
						<ui:define name="label">Tags</ui:define>
						<p:inputText id="simulado_tags" value="#{simuladoHome.listTags}">

						</p:inputText>
					</s:decorate>

					<s:decorate id="dataCriacaoField" template="/layout/display.xhtml">
						<ui:define name="label">Data criação</ui:define>
						<h:outputText value="#{simuladoHome.instance.dataCriacao}">
							<s:convertDateTime type="both" dateStyle="short" />
						</h:outputText>

					</s:decorate>



					<div style="clear: both">
						<span class="required">*</span> Campos Obrigatórios
					</div>

				</p:panel>

				<div class="actionButtons">

					<p:commandButton id="save" value="Salve" 
						action="#{simuladoHome.persist}" disabled="#{!simuladoHome.wired}"
						rendered="#{!simuladoHome.managed}">
						<s:conversationId />
					</p:commandButton>

					<p:commandButton id="update" value="Salve"
						action="#{simuladoHome.update}" rendered="#{simuladoHome.managed}">
						<s:conversationId />
					</p:commandButton>

					<p:commandButton id="delete" value="Delete"
						action="#{simuladoHome.remove}" immediate="true" ajax="false"
						rendered="#{simuladoHome.managed}" />

					<p:button id="VoltaEdit" value="Volta" 
						outcome="/pages/SimuladoList.xhtml" rendered="#{simuladoHome.managed}" >
						<s:conversationId />
						<s:conversationPropagation type="end"/>
					</p:button>

					<p:button id="VoltaAdd" value="Volta" propagation="end"
						outcome="/pages/#{empty simuladoFrom ? 'SimuladoList' : simuladoFrom}.xhtml"
						rendered="#{!simuladoHome.managed}" >
						<s:conversationId />
						<s:conversationPropagation type="end"/>
					</p:button>

				</div>

				<p:panel>
					<div class="results" id="questoes">
						<p:panel rendered="#{simuladoHome.managed}">
							<f:facet name="header">Questões</f:facet>
							<h:outputText value="Simulado sem questões"
								rendered="#{empty listQuestao}}" />

							<p:dataTable id="questoesList" var="_questao" rowIndexVar="row"
								value="#{listQuestao}" rendered="#{not empty listQuestao}">
								<p:column>
									<f:facet name="header">
										<h:outputText value="#" />
									</f:facet>
									<h:outputText value="#{row+1}" escape="false">

									</h:outputText>
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Descrição" />
									</f:facet>
									<h:outputText value="#{_questao.descricao}" escape="false">
										<f:converter converterId="br.com.simulador.TextConverterShort"></f:converter>
									</h:outputText>
								</p:column>
								<p:column styleClass="action">
									

									<p:commandButton action="/pages/QuestaoEdit.xhtml" value="Editar" icon="ui-icon-edit"
										id="questaoEdit" >
										<f:setPropertyActionListener target="#{simuladoHome.questao}" value="#{_questao}"/>
									</p:commandButton>
								</p:column>
								<f:facet name="footer">
									<p:dataScroller id="datascrollerQuestoes" />
								</f:facet>
							</p:dataTable>
							<s:div styleClass="actionButtons" rendered="#{empty from}">
								<p:commandButton action="/pages/QuestaoEdit.xhtml" 
								    actionListener="#{simuladoHome.addQuestao()}"
									id="create"
									value="Nova questão" ajax="false">
									<f:param name="cid" value="#{conversation.id}"></f:param>
									<s:conversationPropagation type="join"/>
								</p:commandButton>

							</s:div>
						</p:panel>
					</div>
			</p:panel>
		</h:form>

	</ui:define>

</ui:composition>
